<template>
  <div id="app">
    <nav-header></nav-header>
    <app-fixed></app-fixed>
    <router-view/>
    <nav-footer></nav-footer>
  </div>
</template>

<script>
import NavHeader from "@/components/NavHeader"
import NavFooter from "@/components/NavFooter"
import AppFixed from "@/components/AppFixed"
export default {
  name: 'App',
  components: {
    NavHeader,
    NavFooter,
    AppFixed
  },
  created () {
    this.isPhone();
    this.resize()
  },
  methods: {
    //判断电脑是否是PC
      IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
              flag = false;
              break;
            }
        }
        return flag;
      },
      // 跳转
      isPhone() {
        let hasPc = this.IsPC()
        if (!hasPc) {
            let http = window.location
            let control = http.protocol
            let host = http.host
            let url = `${control}//${host}/mobile`
            window.location.href = url 
        }
      },
      resize() {
        let self = this
         window.onresize = function name() {
            
              let hasPc = self.IsPC()
              if (!hasPc) {
                let http = window.location
                let control = http.protocol
                let host = http.host
                let url = `${control}//${host}/mobile`
                window.location.href = url
              } 
        }
      },
  },
}
</script>

<style>
html, 
body, 
#app {

  margin: 0 auto;
}
#app {
  width: 100%;
  min-width: 1200px;
  margin: 0 auto;
}
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
</style>
